<template>
  <div class="explain-wrap">
    <el-dialog
      custom-class="explain-dialog"
      :visible.sync="dialogFlag"
      :close-on-click-modal="false"
      :lock-scroll="false"
      :fullscreen="true"
      :show-close="false"
    >
      <!-- 已认证 -->
      <div v-if="showType == 0" class="certified-wrap">
        <img class="success-img jiance-img" src="@/assets/jiance.png" alt />
        <h1>检测实名认证流程中，正在为您跳转...</h1>
      </div>

      <!-- 未认证 -->
      <div v-else-if="showType == 1">
        <div class="explain-content">
          <div class="explain-banner">
            <div class="explain-top">
              <div class="explain-top-content">
                <h1>云木屋</h1>
                <span>欢迎加入云木屋！</span>
              </div>
            </div>
            <div class="banner-content">
              <div class="explain-header">
                <div class="explain-header-left">
                  <h1>申请流程</h1>
                  <h2>PROCEDURE</h2>
                </div>
                <div class="explain-header-right">
                  <div class="explain-header-right-item">
                    <p>1</p>
                    <span>实名认证</span>
                  </div>
                  <div class="dian dian1">
                    <p>● ● ● ● ● ●</p>
                  </div>
                  <div class="explain-header-right-item">
                    <p>2</p>
                    <span>开通电子合同服务</span>
                  </div>
                  <div class="dian dian2">
                    <p>● ● ● ● ● ●</p>
                  </div>
                  <div class="explain-header-right-item">
                    <p>3</p>
                    <span>签署合同</span>
                  </div>
                </div>
              </div>
              <div class="explain-title">
                <h1>PROCEDURE</h1>
                <h2>认证类型</h2>
              </div>
              <div class="select-wrap">
                <div class="select-personal">
                  <img src="@/assets/authentication/icon1.png" alt="个人认证" />
                  <h2>个人实名认证</h2>
                  <div class="select-tip">
                    <p>以个人身份证即可认证</p>
                  </div>
                  <p class="authentication-btn" @click="toAuthentication(1)">前往认证</p>
                </div>
                <div class="select-enterprise">
                  <img src="@/assets/authentication/icon2.png" alt="企业认证" />
                  <h2>企业实名认证</h2>
                  <div class="select-tip">
                    <p>需持营业执照（含个体工商户），认证人需为企业法定代表人</p>
                  </div>
                  <p class="authentication-btn" @click="toAuthentication(0)">前往认证</p>
                </div>
              </div>
            </div>
          </div>

          <div class="explain-center">
            <div class="center-why">
              <p class="center-title">为什么要进行实名认证</p>
              <span>根据国家工商总局《网络交易管理办法》第二章第七条，第八条以及网络实名制规定要求，从事网络商品交易及有关服务的经营者需要进行实名备案</span>
            </div>
            <div class="center-process">
              <p class="center-title">实名认证流程</p>
              <div class="process-content process-personal">
                <p class="personal-title">个人认证</p>
                <i class="line-x"></i>
                <div class="process-item">
                  <img src="@/assets/authentication/c-icon1.png" alt="个人信息" />
                  <p>填写个人信息</p>
                  <i></i>
                  <p>真实姓名</p>
                  <p>居民身份证号码</p>
                </div>

                <i class="line-x"></i>
                <div class="process-item">
                  <img src="@/assets/authentication/c-icon2.png" alt="二次验证" />
                  <p>二次验证</p>
                  <i></i>
                  <p>填写注册人手机号码</p>
                  <p>接收验证码</p>
                </div>

                <i class="line-x"></i>
                <div class="process-item">
                  <img src="@/assets/authentication/c-icon3.png" alt="设置交易密码" />
                  <p>设置交易密码</p>
                  <i></i>
                  <p>保障用户交易安全</p>
                </div>

                <i class="line-x"></i>
                <div class="process-item process-item1">
                  <img src="@/assets/authentication/c-icon4.png" alt="认证成功" />
                  <p>认证成功</p>
                  <i></i>
                  <p>成功加入云木屋成为代理商</p>
                </div>
              </div>
              <div class="process-content process-enterprise">
                <p class="enterprise-title">企业认证</p>
                <i class="line-x"></i>
                <div class="process-item">
                  <img src="@/assets/authentication/c-icon5.png" alt="填写企业信息" />
                  <p>填写企业信息</p>
                  <i></i>
                  <p>营业执照信息</p>
                  <p>法人信息</p>
                </div>

                <i class="line-x"></i>
                <div class="process-item">
                  <img src="@/assets/authentication/c-icon6.png" alt="银行账户信息" />
                  <p>银行账户信息</p>
                  <i></i>
                  <p>填写企业银行账户信息</p>
                  <p>等待平台审核</p>
                </div>

                <i class="line-x"></i>
                <div class="process-item">
                  <img src="@/assets/authentication/c-icon7.png" alt="二次验证" />
                  <p>二次验证</p>
                  <i></i>
                  <p>填写注册人手机号码</p>
                  <p>接收验证码</p>
                </div>

                <i class="line-x"></i>
                <div class="process-item process-item1">
                  <img src="@/assets/authentication/c-icon8.png" alt="认证成功" />
                  <p>认证成功</p>
                  <i></i>
                  <p>成功加入云木屋成为代理商</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 实名认证流程异常 -->
      <div v-else-if="showType==2" class="certified-wrap">
        <img class="success-img" src="@/assets/icon-fail.png" alt />
        <h1>实名认证流程异常</h1>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import {
  register,
  personGetIdTpye,
  getProvinceAjax,
  checkSign
} from "@/api/authentication";
export default {
  computed: {
    ...mapGetters(["memberInfo"])
  },
  data() {
    return {
      dialogFlag: true,
      showType: 0
    };
  },
  created() {
    this._register();
    // this._personGetIdTpye();
    // this._getProvinceAjax();
  },
  methods: {
    // 实名认证检测
    _register() {
      register().then(res => {
        console.log("实名认证检测res", res);
        let testCode = res.code;
        // let testCode = 10018;
        if (testCode == 10010) {
          // 实名认证选择页面
          this.dialogFlag = true;
          this.showType = 1;
        } else if (testCode == 10025) {
          // 实名认证流程异常
          this.dialogFlag = true;
          this.showType = 2;
        } else if (
          (testCode >= 10011 && testCode <= 10014) ||
          testCode == 10021 ||
          testCode == 10022 ||
          (testCode == 10020 && this.memberInfo.yst_user_type == 1)
        ) {
          // 认证未完成跳转到个人认证页面
          this.$router.push({
            name: "personal",
            params: {
              code: testCode
            }
          });
        } else if (
          (testCode >= 10015 && testCode <= 10019) ||
          testCode == 10023 ||
          testCode == 10024 ||
          testCode == 10025 ||
          (testCode == 10020 && this.memberInfo.yst_user_type == 2)
        ) {
          // 认证未完成跳转到企业认证页面
          console.log("认证未完成跳转到企业认证页面", testCode);

          this.$router.push({
            name: "enterprise",
            params: {
              code: testCode
            }
          });
        }
      });
    },

    // 前往认证
    toAuthentication(params) {
      if (params) {
        this.$router.push({
          name: "personal",
          params: {
            code: 10011
          }
        });
      } else {
        this.$router.push({
          name: "enterprise",
          params: {
            code: 10015
          }
        });
      }
    },
    // 去首页
    toHome() {
      this.$router.push({
        name: "homepage"
      });
    }
    // // 获取身份证类型数据
    // _personGetIdTpye() {
    //   personGetIdTpye().then(res => {
    //     let arr = [];
    //     for (let i in res.data.cardType) {
    //       arr.push({
    //         value: i,
    //         label: res.data.cardType[i]
    //       });
    //     }
    //     this.$store.commit("SET_PERSONCARDTYPE", arr);
    //   });
    // },

    // // 获取省份列表数据
    // _getProvinceAjax() {
    //   getProvinceAjax().then(res => {
    //     console.log("获取省份列表数据res", res.data);
    //     this.$store.commit("SET_PROVINCELIST", res.data);
    //   });
    // }
  }
};
</script>

<style lang='scss'>
.explain-wrap {
  .explain-dialog {
    .el-dialog__header {
      padding: 0;
    }
    .el-dialog__body {
      padding: 0;
    }
  }
}
</style>

<style lang="scss" scoped>
.explain-wrap {
  .certified-wrap {
    text-align: center;
    margin-top: 200px;
    img {
      width: 80px;
      height: 100px;
      &.jiance-img {
        width: auto;
        height: auto;
      }
    }
  }
  .explain-content {
    width: 100%;
    background: #fff;
    position: relative;
    z-index: 10;
    overflow: hidden;
    .explain-banner {
      width: 100%;
      padding-bottom: 90px;
      background: url("../../assets/authentication/bannerBg.png") no-repeat;
      background-size: cover;
      position: relative;
      overflow: hidden;
      .explain-top {
        height: 60px;
        border-bottom: 1px solid #f1f1f1;
        box-shadow: 0px 2px 5px #f1f1f1;
        .explain-top-content {
          width: 1200px;
          margin: 0 auto;
          position: relative;
          h1 {
            display: inline-block;
            line-height: 60px;
            font-size: 30px;
            font-weight: bold;
            background-image: linear-gradient(0deg, #ff9303 0%, #fe6018 100%);
            -webkit-background-clip: text;
            color: transparent;
            margin: 0;
          }
          span {
            display: inline-block;
            vertical-align: top;
            margin-left: 30px;
            font-size: 16px;
            font-weight: 400;
            color: rgba(51, 51, 51, 1);
            position: absolute;
            top: 50%;
            left: 80px;
            transform: translateY(-50%);
          }
        }
      }
      .banner-content {
        width: 1200px;
        margin: 0 auto;
        padding-top: 70px;
        position: relative;
        z-index: 12;
        .explain-header {
          width: 100%;
          height: 160px;
          background: linear-gradient(to right, #114f97, #0f59ab);
          display: flex;
          justify-content: space-between;
          padding: 0 150px 0 80px;
          line-height: 0;
          color: #fff;
          .explain-header-left {
            margin: auto 0;
            font-family: Source Han Sans SC;
            line-height: 5px;
            font-weight: bold;
            h1 {
              font-size: 32px;
            }
            h2 {
              font-size: 32px;
              opacity: 0.04;
            }
          }
          .explain-header-right {
            display: flex;
            text-align: center;
            font-size: 16px;
            margin: auto 0;
            position: relative;
            .explain-header-right-item {
              p {
                display: block;
                width: 35px;
                height: 35px;
                line-height: 31px;
                border: 2px solid #fff;
                border-radius: 50%;
                margin: 0 auto;
                margin-bottom: 30px;
                font-family: Bebas;
              }
              span {
                font-weight: 300;
              }
            }
            .dian {
              font-size: 14px;
              display: inline-block;
              background-image: linear-gradient(0deg, #ccc 0%, #fff 100%);
              -webkit-background-clip: text;
              color: transparent;
              letter-spacing: 2px;
              &.dian1 {
                margin-left: 30px;
              }
              &.dian2 {
                margin-right: 30px;
              }
            }
          }
        }
        .explain-title {
          text-align: center;
          position: relative;
          height: 200px;
          h1 {
            font-size: 48px;
            font-family: Source Han Sans SC;
            font-weight: 800;
            color: rgba(51, 51, 51, 1);
            opacity: 0.09;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            top: 20px;
          }
          h2 {
            font-size: 32px;
            font-family: Microsoft YaHei;
            font-weight: bold;
            color: rgba(17, 17, 17, 1);
            line-height: 200px;
          }
        }
      }
    }
  }

  .select-wrap {
    width: 100%;
    display: flex;
    background: #fff;
    div {
      width: 50%;
      text-align: center;
      margin: 70px 0 80px 0;
      font-size: 16px;
    }
  }
  .select-personal {
    box-sizing: border-box;
    border-right: 1px solid #f1f1f1;
  }
  .select-wrap div h2 {
    margin-top: 24px;
    font-size: 20px;
    font-weight: bolder;
  }
  .select-wrap div.select-tip {
    width: 100%;
    height: 0;
    margin: 22px 0 82px 0;
  }
  .select-tip p {
    display: inline-block;
    width: 55%;
    line-height: 30px;
  }
  .select-wrap .authentication-btn {
    display: inline-block;
    width: 200px;
    height: 45px;
    background: linear-gradient(to right, #ceab6e, #f9cd79);
    margin-top: 35px;
    color: #613a0e;
    line-height: 45px;
    transition: all 0.5s;
    cursor: pointer;
  }

  .explain-center {
    text-align: center;
    padding: 0 13px 65px 13px;
    overflow: hidden;
  }
  .center-why {
    margin-top: 80px;
  }
  .center-title {
    font-size: 28px;
    margin-bottom: 70px;
  }
  .center-why span {
    font-size: 16px;
  }

  .center-process {
    padding-top: 80px;
    width: 1200px;
    margin: 0 auto;
  }
  .process-content {
    display: flex;
    justify-content: space-between;
    position: relative;
    transition: all 1s;
  }
  .process-item {
    width: 160px;
  }
  .line-x {
    display: block;
    width: 63px;
    height: 1px;
    background: #dee3f0;
    margin: 75px 0;
  }
  .process-personal {
    margin-bottom: 90px;
  }
  .process-personal-active {
    margin-bottom: 90px;
    position: relative;
    bottom: 0;
  }
  .process-enterprise-active {
    position: relative;
    bottom: 0;
    opacity: 1;
  }
  .personal-title,
  .enterprise-title {
    display: inline-block;
    width: 130px;
    height: 45px;
    color: #fff;
    font-size: 17px;
    font-weight: bolder;
    line-height: 45px;
    border-radius: 50px;
    margin: 53px 0;
  }
  .personal-title {
    background: linear-gradient(to right, #161f7c, #2c53bf);
  }
  .enterprise-title {
    background: linear-gradient(to right, #d69f38, #f4c15c);
  }
  .process-item img {
    margin-bottom: 20px;
  }
  .process-item i {
    display: block;
    width: 23px;
    height: 1px;
    background: #162ca5;
    margin: 0 auto;
    margin-top: 15px;
    margin-bottom: 10px;
  }
  .process-item p {
    font-size: 16px;
    line-height: 35px;
  }
  .process-item p:nth-of-type(1) {
    font-size: 19px;
    font-weight: bolder;
  }
}
</style>